package com.headingdata.exercise;

import java.util.Scanner;

public class Test3 {

    public static void main(String[] args) {
        //根据评委人数，选手打分，[0-100],去掉最高分、最低分求平均分，得到最终分数
        double averageScore = getAverageScore(6);
        System.out.println(averageScore);
    }
    /**
     * param  number [int]
     * */
    public static double getAverageScore(int number){
        double[] scores = new double[number];
        Scanner scan = new Scanner(System.in);
        double sum = 0;
        double minScore = 0;
        double maxScore = 0;
        for (int i = 0; i < scores.length; i++) {
            System.out.println("请输入第" + (i + 1) + "位评委分数:");
            double score = scan.nextDouble();
            scores[i] = score;
            sum += score;
            if(i == 0){
                minScore = scores[0];
                maxScore = scores[0];
            }
            if(score > maxScore){
                maxScore = score;
            }
            if(score < minScore){
                minScore = score;
            }

        }
        double averageScore = (sum - maxScore -minScore)/(number-2);
        return  averageScore;
    }
}
